﻿@model MembershipUserCollection
@using ElearningOUHv2.Models;
@{
    ViewBag.Title = "Index";
    IEnumerable<Afdeling> afdeling = ViewBag.Afdeling as IEnumerable<Afdeling>;
    Session.Add("help", "Account/Index");
}
@*<fieldset>
@Html.Label("Afdeling")
@Html.DropDownList("afd", new SelectList(afdeling.Select(e => e.afdelingsNavn)))
</fieldset>*@
<h2>
    Bruger Administration</h2>
<fieldset>
    <legend>Brugere</legend>
    <table>
        <tr>
            <th>
                Active
            </th>
            <th>
                Bruger Navn
            </th>
            <th>
                Email
            </th>
            <th>
                Rediger
            </th>
            <th>
                Slet
            </th>
        </tr>
        @foreach (MembershipUser user in Model)
        {
            <tr>
                <td>
                    <form action="">@Html.CheckBox("isApproved", user.IsApproved)</form>
                </td>
                <td>
                    @if (Roles.IsUserInRole(@user.UserName, "Administrator"))
                    {
                        <font color="red">@user.UserName</font>
                    }
                    else
                    {
                        @user.UserName            
                    }
                </td>
                <td>@user.Email
                </td>
                <td>@Html.ActionLink("Rediger", "ChangeUser", new { input = user.ProviderUserKey })
                </td>
                <td>
                    @if (user.UserName == "admin")
                    {
                        @MvcHtmlString.Create("Kan ikke slettes");
                    }
                    else
                    {
                        @Html.ActionLink("Slet Bruger", "DeleteUser", new { input = user.ProviderUserKey })
                    }
                </td>
            </tr>
        }
    </table>
    <p>
        <font color="red">Administrator</font> <font color="black">Normal User</font></p>
    <p>@Html.ActionLink("Registrer ny bruger", "CreateNewUser")
    </p>
</fieldset>
<div>@Html.ActionLink("Tilbage til listen", "IndexAdmin", "Emne")</div>
